﻿<%@ WebHandler Language="C#" Class="NewsAdd" %>

using System;
using System.Web;
using System.Web.SessionState;


public class NewsAdd : IHttpHandler, IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "application/json;charset=UTF-8";

        /* 管理员信息验证 */
        if (!Admins.IsLogin(true))
            Utils.ShowEnd(context, -2);

        /* 外部数据接受 */
        int Item_Id = Convert.ToInt32(context.Request.Params["Item_Id"].ToString().Trim());
        int Item_Column = Convert.ToInt32(context.Request.Params["Item_Column"].ToString().Trim());
        int Orders = Convert.ToInt32(context.Request.Params["Orders"].ToString().Trim());
        int Item_Lang = Convert.ToInt32(context.Request.Params["Lang"].ToString().Trim());
        DateTime Item_Time = Convert.ToDateTime(context.Request.Params["Item_Time"].ToString().Trim());
        DateTime Maturity_Time = Convert.ToDateTime(context.Request.Params["Maturity_Time"].ToString().Trim());
        string Item_Title = context.Request.Params["Item_Title"].ToString().Trim();
        string Item_Story = context.Request.Params["Item_Story"].ToString().Trim();
        string Item_Summary = context.Request.Params["Item_Summary"].ToString().Trim();
        string Item_Url = context.Request.Params["Item_Url"].ToString().Trim();

        string Property1 = context.Request.Params["Property1"].ToString().Trim();
        string Property2 = context.Request.Params["Property2"].ToString().Trim();
        string Property3 = context.Request.Params["Property3"].ToString().Trim();
        string Property4 = context.Request.Params["Property4"].ToString().Trim();
        string Property5 = context.Request.Params["Property5"].ToString().Trim();
        string Property6 = context.Request.Params["Property6"].ToString().Trim();
        string Property7 = context.Request.Params["Property7"].ToString().Trim();
        string Property8 = context.Request.Params["Property8"].ToString().Trim();
        string Property9 = context.Request.Params["Property9"].ToString().Trim();
        string Property10 = context.Request.Params["Property10"].ToString().Trim();

        /* 完整性验证 */
        Verification verification = new Verification();
        if (!verification.VerificationMinMaxValue(Item_Lang,1,255))
            Utils.ShowEnd(context, -1);
        if (!verification.VerificationMinMaxValue(Orders, 1, 255))
            Utils.ShowEnd(context, -1);
        if (!verification.VerificationMinMaxValue(Item_Column, 1, 4000))
            Utils.ShowEnd(context, -1);
        if(!verification.Reg(Item_Title,verification.Title))
            Utils.ShowEnd(context, -1);

        /* 编码转换 */
        Item_Title = Utils.HtmlEncode(Item_Title);
        Item_Story = Utils.HtmlEncode(Item_Story);
        Property1 = Utils.HtmlEncode(Property1);
        Property2 = Utils.HtmlEncode(Property2);
        Property3 = Utils.HtmlEncode(Property3);
        Property4 = Utils.HtmlEncode(Property4);
        Property5 = Utils.HtmlEncode(Property5);
        Property6 = Utils.HtmlEncode(Property6);
        Property7 = Utils.HtmlEncode(Property7);
        Property8 = Utils.HtmlEncode(Property8);
        Property9 = Utils.HtmlEncode(Property9);
        Property10 = Utils.HtmlEncode(Property10);
        Item_Url = Utils.UrlEncode(Item_Url);
        Item_Summary = Utils.HtmlCodeClear(Utils.UrlDecode(Item_Summary));
        Item_Summary = Utils.HtmlEncode(Item_Summary);

        Videos video = new Videos();
        Utils.ShowEnd(context, video.AddEdit(Item_Id, Item_Title, Item_Story, Item_Summary, Item_Column, Orders, Item_Time, Maturity_Time, Item_Lang, Item_Url, Property1, Property2, Property3, Property4, Property5, Property6, Property7, Property8, Property9, Property10).ToString());

    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }


}